package com.qianyu.project.mapper.provider.smj;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface smjLaberControllerDao {

    //添加合同信息
    @Insert("insert into labor_contract(create_date, id, contract_name, p_id, contract_type, contract_amount, start_date, end_date, labor_org_id, settle_type, advance_pay, deposit_amount, payment_type, contract_signatory, pay_condition, main_term, comment, attach_ids,amount_upper) " +
            "value(#{create_date}, #{id}, #{contract_name}, #{p_id}, #{contract_type}, #{contract_amount}, #{start_date}, #{end_date}, #{labor_org_id}, #{settle_type}, #{advance_pay}, #{deposit_amount}, #{payment_type}, #{contract_signatory}, #{pay_condition}, #{main_term}, #{comment}, #{attach_ids}, #{amount_upper})")
    void Addlaber(String create_date, String id, String contract_name, String p_id, String contract_type, String contract_amount, String start_date, String end_date, String labor_org_id, String settle_type, String advance_pay, String deposit_amount, String payment_type, String contract_signatory, String pay_condition, String main_term, String comment, String attach_ids,String amount_upper);

    //添加工程量信息
    @Insert("insert into labor_work_list values(null,#{id},#{work_content},#{unit},#{work_count},#{unit_price},#{sum_price})")
    void Addlaborworklist(String work_content, String unit, String work_count, String unit_price, Integer sum_price, String id);


    //修改审批状态
    @Update("update labor_contract set approve_status = #{approveStatus} where id=#{id}")
    void UpdateApproveStatus(Integer approveStatus, String id);

    //修改文件附录的上传人姓名
    @Update("update attachemen_info set infoname = #{infoname} where id in (${ids})")
    void UpdateInfo(String ids, String infoname);

    //获取工程量清单
    @Select("select * from labor_work_list where labor_id =#{id}")
    List<Map<String ,Object>> getWorkList(String id);

    //获取流程id
    @Select("select fid from form  where id=#{id} and target ='labor_contract'")
    String getFid(String id);

    //获取审批流程
    @Select("select fa.*,fn.flowNodeName,su.user_realname from form_audit fa ,flow_node fn ,system_user su where fa.fid=#{fid} and fa.flowNodeId = fn.flowNodeId and fa.eid=su.id")
    List<Map<String, Object>> getfromaudit(String fid);


}
